﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ATMAaronKnoll
{
    public abstract class Accounts
    {
        private static Customer currentUser;
        private static List<Customer> customers = new List<Customer>();

        public static void SetUser(Customer user)
        {
            currentUser = user;
        }

        public static void Logoff()
        {
            currentUser = null;
        }

        public static bool AuthenticateUser(int accountInput, String pinInput)
        {
            //when authen. user, we have user and id but it goes thru each customer to find which one has the matching account/pin #s. result comes out as that list.
            Customer result = customers.Find(
            delegate(Customer user)
            {
                return user.accountNumber == accountInput;
            });

            if (result != null)
            {
                if (result.pin == pinInput)
                {
                    currentUser = result;
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }

        public static int GetBalance()
        {
            return currentUser.balance;
        }

        public static bool WithdrawCash(int amount)
        {
            if (currentUser.balance >= amount)
            {

                currentUser.balance = currentUser.balance -amount;
                return true;
            }
            else
            {
                return false;
            }
        }

        public static void DepositCash(int depositAmount)
        {
            currentUser.balance = currentUser.balance + depositAmount;
        }
            

        public static void CreateAccount(String name, String address, String state, String zip, int accountNumber, String pin, int balance)
        {
            customers.Add(new Customer(name, address, state, zip, accountNumber, pin, balance));
        }
    }

    public class Customer
    {
        public String name { get; set; }
        public String address { get; set; }
        public String state { get; set; }
        public String zip { get; set; }
        public int accountNumber { get; set; }
        public String pin { get; set; }
        public int balance { get; set; }

        public Customer(String name, String address, String state, String zip, int accountNumber, String pin, int balance)
        {
            this.name = name;
            this.address = address;
            this.state = state;
            this.zip = zip;
            this.accountNumber = accountNumber;
            this.pin = pin;
            this.balance = balance;
        }
    }
}

      